package oj.oj206;


public class Solution {
    public  ListNode reverseList(ListNode head) {
        ListNode cur = head;
        ListNode prev = null;
        while (cur!=null){
            ListNode next = cur.next;
            cur.next = prev;
            prev = cur;
            cur = next;
        }
        return prev;
    }
    public void Bianli_print(ListNode head){
        ListNode cur = head;
        while (cur!=null){
            System.out.println(cur.val);
            cur = cur.next;
        }
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        ListNode n1 = new ListNode(100);
        ListNode n2 = new ListNode(200);
        ListNode n3 = new ListNode(300);
        ListNode n4 = new ListNode(400);
        n1.next = n2;
        n2.next = n3;
        n3.next = n4;
        n4.next = null;
        solution.Bianli_print(n1);
        solution.Bianli_print(solution.reverseList(n1));
    }
}
